﻿<%@ Page Title="" Language="C#" MasterPageFile="~/web/common/Common.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="shop.web.view_admin.user.Login" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>登录</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="layui-container fly-marginTop">
        <div class="fly-panel fly-panel-user" pad20>
            <div class="layui-tab layui-tab-brief" lay-filter="user">
                <ul class="layui-tab-title">
                    <li class="layui-this">登入</li>
                    <li><a href="register.aspx">注册</a></li>
                </ul>
                <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
                    <div class="layui-tab-item layui-show">
                        <div class="layui-form layui-form-pane">
                            <form method="get" action="../../../handler/UserHandler.ashx">
                                <div class="layui-form-item">
                                    <input type="hidden" name="method" value="login" />
                                    <label for="L_email" class="layui-form-label">用户名</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="name" name="userName" required lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入用户名" value="<%=userName %>">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label for="L_pass" class="layui-form-label">密码</label>
                                    <div class="layui-input-inline">
                                        <input type="password" id="L_pass" name="password" required lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入密码" value="<%=password %>">
                                    </div>
                                </div>
                               <%-- <div class="layui-form-item">
                                    <label for="L_vercode" class="layui-form-label">验证码</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="L_vercode" name="vercode" required lay-verify="required" placeholder="验证码" autocomplete="off" class="layui-input">
                                    </div>

                                </div>--%>

                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="">记住密码</label>
                                        <input type="checkbox" class="remenber" lay-skin="switch" name="remember" value="1" lay-text="记住|取消"  lay-filter="remmember" checked="checked">
                                    </div>
                                    <button class="layui-btn login" lay-filter="*" type="button">立即登录</button>
                                   <%-- <span style="padding-left: 20px;">
                                        <a href="forget.html">忘记密码？</a>
                                    </span>--%>
                                </div>

                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        layui.use('form', function () {
            var form = layui.form;
           
            form.on('switch(remmember)', function (data) {
              
                 console.log(data.elem.checked); 
                var checked = data.elem.checked;
                if (checked == false) {
                    layer.confirm('确定清除cookie?', { icon: 3, title: '提示' }, function (index) {
                    //do something
                    <%Response.Cookies["username"].Expires = DateTime.Now.AddDays(-1);
                         Response.Cookies["password"].Expires = DateTime.Now.AddDays(-1);
                        %>
                        layer.close(index);
                    });
                }
                       
            });
        });
        var remember = <%=remember%>;
        console.log(remember)
        if (remember === 1) {
            $(".remember").attr("checked","checked");
        }

        //var layer = layui.layer;
        $(".login").click(function () {
            $.ajax({
                url: $('form').attr('action'),
                type: "post",
                data: $("form").serialize(),
                success: function (data) {

                    console.log(data)
                    var obj = JSON.parse(data);

                    if (obj.ErrorCode === 0) {

                        //成功
                        layer.msg("登录成功", { icon: 6 }, function () {
                            if (obj.Data.Rank == 1) {
                                window.location.href = "/index.aspx";
                            } else if (obj.Data.Rank == 2 || obj.Data.Rank == 3 || obj.Data.Rank == 4) {
                                window.location.href = "/web/view_admin/index.aspx";
                            }
                        });


                    } else {
                        layer.msg(obj.Message, { icon: 2 })
                    }
                }
            })
        })
    </script>
</asp:Content>
